<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 
        .prevent修饰符:
          阻止当前事件的默认行为
        .once修饰符:
          当前事件只能触发一次
       -->
      <button @contextmenu.prevent.once="contextMenu">
        右键我,看我有没有菜单了
      </button>
      <!-- 
        .capture修饰符:
          控制当前事件在捕获阶段触发(如果不写,默认都是在冒泡阶段触发)
        .stop修饰符:
          阻止当前事件的传播
          如果要阻止捕获,在最外层元素上书写
          如果要阻止冒泡,在最内层元素上书写
       -->
      <div @click.capture.stop="outerClick"><!--  @click.capture.stop只会触发到outer -->
        outer
        <div @click="innerClick">
          inner
          <div @click.stop="contentClick">content</div>
        </div>
      </div>

      <hr />

      <!-- 
        .self修饰符:
          控制只有在当前绑定事件的元素上发生事件,才能触发事件
       -->
      <div @click.self="outerClick">
        outer
        <div>
          inner
          <div @click.self="contentClick">content</div>
        </div>
      </div>

      <!-- 
        按键别名修饰符
          .enter(配合键盘事件使用):当输入回车的时候执行回调函数
       -->
      <input type="text" @keyup.enter="publish" />
      <input type="text" @keyup.delete="publish" />
    </div>
    <script>
        Vue.config.productionTip = false;
        
        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    
                }
            },
            methods: {
            contextMenu() {
                console.log("右键触发");//contentmenu
            },
            outerClick() {
                console.log("outer");
            },
            innerClick() {
                console.log("inner");
            },
            contentClick() {
                console.log("content");
            },
            publish() {
                console.log("publish");
            },
            },
        })
</script>
</body>

</html>